package com.neusoft.ysu.his.controller;


import com.neusoft.ysu.his.entity.CommonResult;
import com.neusoft.ysu.his.entity.Doc;
import com.neusoft.ysu.his.entity.Seek;
import com.neusoft.ysu.his.service.IDocService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 作者：赵子鉴
 * @since 2023-08-25
 */
@RestController
@RequestMapping("/doc")
@CrossOrigin
public class DocController {
    @Autowired
    IDocService docService;
    @PostMapping("/q/see")
    public CommonResult findDocToSee(@RequestBody Seek seek){
        return docService.findDocToSee(seek);
    }
    @GetMapping("/q/byid/{id}")
    public CommonResult findDocById(@PathVariable int id){
        return docService.findDocById(id);
    }

//    以下为基础的增删改查
    @GetMapping("/q/all")
    public CommonResult findAll(){
        return docService.findAll();
    }


    @GetMapping("/q/name")
    public CommonResult findName(){
        return docService.findName();
    }


    @PutMapping("/add")
    public CommonResult insert(@RequestBody Doc doc)
    {
        doc.setId(null);
        doc.setDelmark(0);
        return docService.insert(doc);
    }
    @PostMapping("/update")
    public CommonResult update(@RequestBody Doc doc)
    {
        return docService.updateById(doc);
    }

    @PostMapping("/delet")
    public CommonResult deleteById(@RequestBody Doc doc){
        return docService.deleteById(doc);
    }


}
